//
//  ICMBasicInfoModel.m
//  ICrEAM
//
//  Created by FoREVer_SaD on 16/10/28.
//  Copyright © 2016年 mac. All rights reserved.
//

#import "ICMAppointmentBasicInfoModel.h"
#import "ICMPropertyManager.h"


@implementation ICMAppointmentBasicInfoModel

- (void)setupBasicInfoModelWithBasicInfoView:(ICMGetCarBasicInfoView *)basicInfoView{
    [ICMPropertyManager setAllValueForEmpty:self];
    self.RECEPTION_NO = basicInfoView.RECEPTION_NO?:@"";
    self.RECEPTION_STATUS = basicInfoView.RECEPTION_STATUS?basicInfoView.RECEPTION_STATUS:ICMEnumIntToString(ICMEnumReceptionStatusDefault);
    self.BOOKING_ORDER_NO = basicInfoView.BOOKING_ORDER_NO?basicInfoView.BOOKING_ORDER_NO:@"";
    self.RO_NO = basicInfoView.RO_NO?basicInfoView.RO_NO:@"";
    
    self.VIN = basicInfoView.vinNumberView.contentText;
//    NSString *carArea = [ICrEAMTool getDeatilCodeWithParameterDesc:basicInfoView.selectAreaView.contentText withCode:@"2147"];
    self.LICENSE = [NSString stringWithFormat:@"%@%@",basicInfoView.selectAreaView.contentText?:@"",basicInfoView.plateNumberView.contentText?:@""];
    
    self.OWNER_NAME = basicInfoView.ownerNameView.contentText;
    self.OWNER_NO = basicInfoView.personModel.OWNER_NO;
    
    NSString *owner_property = [ICrEAMTool getDeatilCodeWithParameterDesc:basicInfoView.ownerTypeView.contentText withCode:ICMEnumIntToString(ICMEnumOwnerPropertyPre)];
    self.OWNER_PROPERTY = owner_property?owner_property:@"";
    
    self.SALES_DATE = basicInfoView.invoiceDateView.contentText;
    self.IN_MILEAGE = basicInfoView.currentMileageView.contentText;
    self.OWNER_MOBILE = basicInfoView.ownerPhoneNumberView.contentText;
    
    self.MODEL_CODE = basicInfoView.carTypeView.noStr;
    
    self.OIL_REMAIN = @(basicInfoView.remainingFuel);
    self.DELIVERER = basicInfoView.customerNameView.contentText;
    self.DELIVERER_MOBILE = basicInfoView.customerPhoneNumberView.contentText;
    
    NSString *wash_type = [ICrEAMTool getDeatilCodeWithParameterDesc:basicInfoView.cleanCarView.contentText withCode:ICMEnumIntToString(ICMEnumWashTypePre)];
    self.WASH_TYPE = wash_type?wash_type:@"";
    
    NSString *old_part_process = [ICrEAMTool getDeatilCodeWithParameterDesc:basicInfoView.oldPartsShowView.contentText withCode:[ICrEAMTool isVW]?ICMEnumIntToString(ICMEnumOldPartProcessVWPre):ICMEnumIntToString(ICMEnumOldPartProcessSKPre)];
    self.OLD_PART_PROCESS = old_part_process?old_part_process:@"";
    
    self.CHECK_SPARE_WHEEL = [basicInfoView.spareWheelCheckView.contentText isEqualToString:@"是"]?ICMEnumIntToString(ICMEnumYESOrNOYES):ICMEnumIntToString(ICMEnumYESOrNONO);
    
    self.DELIVER_ADD = basicInfoView.sendCarAddressView.contentText?basicInfoView.sendCarAddressView.contentText:@"";

    
    NSString *repair_type_string = basicInfoView.repairTypeView.contentText?basicInfoView.repairTypeView.contentText:@"";
    
    self.REPAIR_TYPE_CODE = @"";
    NSMutableArray *type_codes = [NSMutableArray array];
    if (![repair_type_string isEqualToString:@""]) {
        NSArray *repair_type_strings = [repair_type_string componentsSeparatedByString:@","];
        for (NSString *type in repair_type_strings) {
            NSString *code = [ICrEAMTool getRepiarTypeCodeWithRepiarName:type];
            if (code) {
                [type_codes PACA_AddObject:code];
            }
        }
        self.REPAIR_TYPE_CODE = [type_codes componentsJoinedByString:@";"];
    }
    
    
    self.BUSINESS_DESC = basicInfoView.requirementDiscribeView.contentText?basicInfoView.requirementDiscribeView.contentText:@"";
    self.DEPTH_CHECK = basicInfoView.furtherCheckView.contentText?basicInfoView.furtherCheckView.contentText:@"";
}

- (void)setupBasicInfoModelWithAppointmentView:(ICMAppointmentBasicInfoView *)basicInfoView{
    
    self.BOOKING_ORDER_NO = basicInfoView.BOOKING_ORDER_NO?basicInfoView.BOOKING_ORDER_NO:@"";
    
    self.VIN = basicInfoView.vinNumberView.contentText;

    self.LICENSE = [NSString stringWithFormat:@"%@%@",basicInfoView.selectAreaView.contentText?:@"",basicInfoView.plateNumberView.contentText?:@""];
    self.SALES_DATE = basicInfoView.invoiceDateView.contentText;
    self.IN_MILEAGE = basicInfoView.currentMileageView.contentText;
    self.OWNER_NO = basicInfoView.personModel.OWNER_NO;
    self.MODEL_CODE = basicInfoView.carTypeView.noStr;
    self.OWNER_NAME = basicInfoView.ownerNameView.contentText;
    self.OWNER_MOBILE = basicInfoView.ownerPhoneNumberView.contentText;
    
//    NSString *owner_property = [ICrEAMTool getDeatilCodeWithParameterDesc:basicInfoView.ownerTypeView.contentText withCode:@"1190"];
    self.OWNER_PROPERTY = basicInfoView.ownerTypeView.noStr?basicInfoView.ownerTypeView.noStr:@"";
    
    self.DELIVERY_ADDRESS = basicInfoView.sendCarAddressView.contentText?basicInfoView.sendCarAddressView.contentText:@"";
    self.SERVICE_ADVISOR = basicInfoView.SERVICE_ADVISOR;
    
    self.DELIVERER = basicInfoView.customerNameView.contentText;
    self.DELIVERER_MOBILE = basicInfoView.customerPhoneNumberView.contentText;
    
}


@end











